package com.block.datapush.special.factory;

import com.block.common.enums.InfoTypeEnum;
import com.block.common.util.ApplicationContextUtil;
import com.block.datapush.special.service.IDataInfoCommonService;
import com.block.datapush.special.service.infoType.MerchantApiInfoServiceImpl;
import com.block.datapush.special.service.infoType.MerchantCrmInfoServiceImpl;

import java.util.HashMap;
import java.util.Map;

public class InfoTypeFactory {

    private static Map<String, Class<? extends IDataInfoCommonService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(InfoTypeEnum.API.getValue(), MerchantApiInfoServiceImpl.class);
        serviceMap.put(InfoTypeEnum.APIS.getValue(), MerchantApiInfoServiceImpl.class);
        serviceMap.put(InfoTypeEnum.CRM.getValue(), MerchantCrmInfoServiceImpl.class);
    }

    public static IDataInfoCommonService getService(String filterKey){
        if (serviceMap.containsKey(filterKey)){
            Class<? extends IDataInfoCommonService> aClass = serviceMap.get(filterKey);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }

}
